﻿<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Content-type: text/xml;  charset=TIS-620");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
//XML Header
header("content-type:text/xml"); 
createKmlFile();
function parseToXML($htmlStr)
{ 

$xmlStr=str_replace('<','&lt;',$htmlStr); 

$xmlStr=str_replace('>','&gt;',$xmlStr); 

$xmlStr=str_replace('"','&quot;',$xmlStr); 

$xmlStr=str_replace("'",'&#39;',$xmlStr); 

$xmlStr=str_replace("&",'&amp;',$xmlStr); 
$xmlStr=str_replace("",'a',$xmlStr); 

}
function createKmlFile(){

$q=$_GET["q"];
//include('time.php');//เรียกไฟล์เวลา
$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("aris", $con);
mysql_query("SET NAMES UTF8");


		$sql="SELECT
student.id,
student.Pre_st,
student.name_st,
student.sname_st,
student.id_st,
student.class_st,
student.type
FROM
liststgroup
INNER JOIN student ON liststgroup.idSt = student.id
WHERE
liststgroup.idGroup = '$q'";

$result = mysql_query($sql);
echo '<CATALOG>';
while ($row1 = mysql_fetch_array($result)) {
		// $sqlProject="SELECT * FROM project WHERE idStu = '$idstu'"
		echo '<group>';
		echo '<id1>'.$row1['id'].'</id1>';
		echo '<id2>'.$row1['Pre_st'].'</id2>';
		echo '<id3>'.$row1['name_st'].'</id3>';
		echo '<id4>'.$row1['sname_st'].'</id4>';
		echo '<id5>'.$row1['id_st'].'</id5>';
		echo '<id6>'.$row1['class_st'].'</id6>';
		echo '<id7>'.$row1['type'].'</id7>';
		echo '</group>';

}
//echo $sql;
echo '</CATALOG>';

//echo $sql;
mysql_close($con);
}
?>